﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../scripts/boot.js" type="text/javascript"></script>
    <script src="../scripts/swfupload/swfupload.js" type="text/javascript"></script>
    <script type="text/javascript">
        $.ajax({
            url: "../data/system.aspx?method=309",
            async: false,
            success: function (text) {
                if (text == "no")
                    window.location = "../system/error.html";
                else if (text == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                    var tabs = parent.mini.get("mainTabs");
                    var tab = tabs.getTab("tab$309");
                    tabs.removeTab(tab);
                }
            }
        });
    </script>
</head>
<body>
    <div class="mini-toolbar" style="border-bottom: 0;">
        <table>
            <tr>
                <td>
                    名称：
                    <input class="mini-textbox" id="key" emptytext="关键字" />
                    <a class="mini-button" iconcls="icon-search" plain="true" onclick="search();">查询</a>
                    <span class="separator"></span>
                    <a class="mini-button" plain="true" iconcls="icon-excel" onclick="excelRow()">导入数据</a>
                    <span class="separator"></span>
                    <a class="mini-button" iconcls="icon-unlock" plain="true" onclick="lockRows(1);">显示</a>
                    <a class="mini-button" iconcls="icon-lock" plain="true" onclick="lockRows(0)">隐藏</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-fit" >
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" allowresize="true"
            idfield="id" multiselect="true" url="../data/system.aspx?method=GetExamList" sizeList="[15,20,50,100]" pageSize="15">
            <div property="columns">
                <div type="checkcolumn">
                </div>
                <div field="ex_title" width="200px" headeralign="center" align="left" allowsort="true" renderer="onNameRenderer">
                    名称</div>
                <div field="ex_state" width="120px" headeralign="center" align="center" allowsort="true" renderer="onStateRenderer">
                    状态</div>
                <div field="ex_time" width="100px" headeralign="center" align="center" allowsort="true" dateformat="yyyy-MM-dd">
                    上传时间</div>
                <div field="su_login" width="100px" headeralign="center" align="center" allowsort="true">
                    上传人</div>
                <div field="ex_memo" width="120px" headeralign="center" align="center" allowsort="true">
                    备注</div>
            </div>
        </div>
    </div>
    <div id="editWindow" class="mini-window" title="导入分数" style="width: 500px; height:auto;" showmodal="true"
        allowresize="false" allowdrag="true" showFooter="true">
        <div id="editForm" class="form">
            <table style="width: 98%; height: 100%;">
                <tr style="height: 20px">
                    <td class="tdtitle" style="width: 100px;">
                        <span class="red">*</span>标题：
                    </td>
                    <td class="tdtext">
                        <input id="ex_title" name="ex_title" class="mini-textbox" style="width:380px;" required="true"/>
                    </td>
                </tr>
                <tr style="height: 20px">
                    <td class="tdtitle">
                       <span class="red">*</span>上传文件：
                    </td>
                    <td class="tdtext">
                        <input id="fileupload1" class="mini-fileupload" name="Fdata"
                        flashUrl="../scripts/swfupload/swfupload.swf"
                        uploadUrl="../data/system.aspx?method=ScoreUpload"
                        onuploadsuccess="onUploadSuccess" style="width:380px;"
                        onuploaderror="onUploadError" onfileselect="onFileSelect"
                        />
                    </td>
                </tr>
                <tr style="height: 20px">
                    <td class="tdtitle">
                        备注：
                    </td>
                    <td class="tdtext">
                        <input class="mini-textarea" id="ex_memo" name="ex_memo" style="width: 380px; height: 50px" />
                    </td>
                </tr>
            </table>
        </div>
        <div property="footer" style="text-align:center;padding:5px;">
            <a class="mini-button" iconcls="icon-upload" onclick="startUpload()">导入</a>
            <span style="display:inline-block;width:25px;"></span>
            <a class="mini-button" style="width:60px;" onclick="closewin()">关闭</a>
        </div>
    </div>
    <script type="text/javascript">
        $.ajaxSetup({
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            complete: function (XMLHttpRequest, textStatus) {
                if (XMLHttpRequest.responseText == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                }
            }
        });

        mini.parse();

        var grid = mini.get("datagrid1");
        search();

        function search() {
            var key = mini.get("key").getValue();
            grid.load({ key: key });
        }

        function excelRow() {
            var form = new mini.Form("#editForm");
            form.reset();
            form.loading();
            form.unmask();
            var win = mini.get("editWindow");
            if (!win.visible)
                win.show();
        }

        function onFileSelect(e) {
            if (e.file.type != ".xls")
                ShowMessage("系统提示", "请选择EXCEL文件！", 2);
        }

        function onUploadSuccess(e) {
            mini.unmask(document.body);
            if (e.serverData == "out") {
                var loginWindow = parent.mini.get("loginWindow");
                if (!loginWindow.visible)
                    loginWindow.show();
                return;
            }
            else if (e.serverData == "no") {
                ShowMessage("系统提示", "对不起，您没有此操作权限！", 3);
                this.setText("");
                return;
            }
            else if (e.serverData == "1") {
                ShowMessage("系统提示", "导入成功！", 1);
                this.setText("");
                mini.get("editWindow").hide();
                grid.reload();
            }
            else if (e.serverData == "0")
                ShowMessage("系统提示", "表格中没数据！", 2);
            else
                ShowMessage("系统提示", "导入失败！", 3);
        }

        function onUploadError(e) {
            mini.unmask(document.body);
            ShowMessage("系统提示", "导入失败！", 3);
        }

        function startUpload() {
            var form = new mini.Form("#editForm");
            form.validate();
            if (form.isValid() == false)
                return;
            var o = form.getData();
            var json = mini.encode(o);
            json = encodeURI(json);
            var fileupload = mini.get("fileupload1");
            fileupload.setUploadUrl("../data/system.aspx?method=ScoreUpload&json=" + json);
            mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '导入中，请稍后...' });
            fileupload.startUpload();
        }

        function closewin() {
            var win = mini.get("editWindow");
            win.hide();
        }

        function onNameRenderer(e) {
            var record = e.record;
            //var s = '<a class="linelink" title="查看详细" href="javascript:void(0);" onclick="lookRow(' + e.record._uid + ')">' + e.value + '</a>';
            var s = '<a class="linelink" target="_blank"  href="/Web/Score/' + record.ex_no + '.html">' + e.value + '</a>';
            return s;
        }

        function onStateRenderer(e) {
            var record = e.record;
            var s;
            if (record.ex_state == 1)
                s = '<font color="#009900">显示</font>';
            else
                s = '<font color="#ff3300">隐藏</font>';
            return s;
        }

        function lookRow(row_uid) {
            var row = grid.getRowByUID(row_uid);
            if (row) {
                var tabs = parent.mini.get("mainTabs");
                var tab = tabs.getTab("tab$309");
                tab.enabled = false;
                showTab(row.ex_no, row.ex_title);
            }
        }

        //打开管理招聘Tab
        function showTab(ex_no, ex_title) {
            var tabs = parent.mini.get("mainTabs");
            var id = "tab$sco";
            var tab = tabs.getTab(id);
            if (!tab) {
                tab = {};
                tab.name = id;
                tab.title = ex_title;
                tab.showCloseButton = true;
                tab.url = "score/list.html?exno=" + ex_no;
                tabs.addTab(tab);
            }
            tabs.activeTab(tab);
        }

        function lockRows(state) {
            var rows = grid.getSelecteds();
            var msg = "隐藏";
            if (state == 0)
                msg = "显示";
            if (rows.length > 0) {
                mini.confirm("确定" + msg + "所选信息吗？", "系统提示",
                    function (action) {
                        if (action == "ok") {
                            mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '操作中，请稍后...' });
                            var ids = "";
                            for (var i = 0; i < rows.length; i++) {
                                ids += rows[i].ex_no + ',';
                            }

                            $.ajax({
                                url: "../data/system.aspx?method=LockExam",
                                type: "post",
                                data: { id: ids, state: state },
                                success: function (ret) {
                                    mini.unmask(document.body);
                                    if (ret == "out") {
                                        var loginWindow = parent.mini.get("loginWindow");
                                        if (!loginWindow.visible)
                                            loginWindow.show();
                                        return;
                                    }
                                    if (ret >= 0) {
                                        ShowMessage("系统提示", "信息" + msg + "成功！", 1);
                                        grid.reload();
                                    }
                                    else
                                        ShowMessage("系统提示", "信息" + msg + "失败！", 3);
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    mini.unmask(document.body);
                                    ShowMessage("系统提示", "信息" + msg + "失败！", 3);
                                }
                            });
                        }
                    }
                );
            } else
                ShowMessage("系统提示", "请选择需要" + msg + "的信息！", 2);
        }
    </script>
</body>
</html>